﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter8.Section3
{
    public class Example01
    {
        public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double[]> F
               = new V.Function.ToLastType<double[], double[]>(vectorField);
            V.VectorField obj = new V.VectorField(F);

            double[] at0 = {2.3,2.4,5.2};
            V.Point p1 = new V.Point(at0);
            double[] at1 = { 5.3, 2.4, 5.2 };
            V.Point p2 = new V.Point(at1);
            double[] at2 = { 2.3, 5.4, 5.2 };
            V.Point p3 = new V.Point(at2);
            result += obj.Potential(p2).ToString() + "\r\n";
            result += potential(p2.Coordinate).ToString() + "\r\n";
            result += obj.Potential(p1).ToString() + "\r\n";
            result += potential(p1.Coordinate).ToString() + "\r\n";
        }
        private double[] vectorField(double[] x)
        {
            double[] f = new double[3];
            f[0] = x[1];
            f[1] = x[2]*Math.Cos(x[1] * x[2])+x[0];
            f[2] = x[1]*Math.Cos(x[1] * x[2]);
            return f;
        }
        private double potential(double[] x)
        {
            return x[0] * x[1] + Math.Sin(x[1] * x[2]);
        }
    }
}
/*
12.6337367323894
12.6337367313737
5.43373673241131
5.43373673137366
*/